{include file=header.html}
<script src="{lib file=mlselection.js}" charset="utf-8"></script>
<script src="{lib file=jquery.plugins/jquery.validate.js}" charset="utf-8"></script>
<style type="text/css">
    .d_inline{display:inline;}
</style>

<script type="text/javascript">
    //<!CDATA[
    var SITE_URL = "{$site_url}";
    var REAL_SITE_URL = "{$real_site_url}";
    $(function() {
        regionInit("region");

        $("#apply_form").validate({
            errorPlacement: function(error, element) {
                element.append(error);
            },
            success: function(label) {
                label.addClass('validate_right').text('OK!');
            },
            onkeyup: false,
            rules: {
                owner_name: {
                    required: true
                },
                store_name: {
                    required: true,
                    remote: {
                        url: 'index.php?app=apply&act=check_name&ajax=1',
                        type: 'get',
                        data: {
                            store_name: function() {
                                return $('#store_name').val();
                            },
                            store_id: '{$store.store_id}'
                        }
                    },
                    maxlength: 20
                },
                tel: {
                    required: true,
                    minlength: 6,
                    checkTel: true
                },
                image_1: {
                    accept: "jpg|jpeg|png|gif"
                },
                image_2: {
                    accept: "jpg|jpeg|png|gif"
                },
                image_3: {
                    accept: "jpg|jpeg|png|gif"
                },
                notice: {
                    required: true
                }
            },
            messages: {
                owner_name: {
                    required: '{$lang.input_owner_name}'
                },
                store_name: {
                    required: '{$lang.input_store_name}',
                    remote: '{$lang.name_exist}',
                    maxlength: '{$lang.note_for_store_name}'
                },
                tel: {
                    required: '{$lang.input_tel}',
                    minlength: '{$lang.phone_tel_error}',
                    checkTel: '{$lang.phone_tel_error}'
                },
                image_1: {
                    accept: '{$lang.select_valid_image}'
                },
                image_2: {
                    accept: '{$lang.select_valid_image}'
                },
                image_3: {
                    accept: '{$lang.select_valid_image}'
                },
                notice: {
                    required: '{$lang.check_notice}'
                }
            }
        });
    });
    //]]>
</script>
<style>
    .apply_form h2 {text-align: center;font-size: 12px;}
    .apply_form input[type="text"] {margin: 6px 10px;padding: 5px 0px;border: #ccc solid 1px;color: #777;width: 300px;}
    .apply_form select {border: 1px solid #A7A6AA;height: 22px;padding: 1px;line-height: 22px;margin-right: 2px;width: 96%;margin: 2px 5px 5px 5px;}
    .apply_form .btn{width: 100%;padding: 8px 0;background: #b00005;background: linear-gradient(to bottom,#9f0207,#b00005);background: -moz-linear-gradient(top, #9f0207,#b00005);background: -webkit-gradient(linear, 0 0, 0 100%, from(#9f0207), to(#b00005));border: #8d0303 solid 1px;border-radius: 3px;color: #fff;}
</style>
<div class="w320 apply_form">
    <form method="post" enctype="multipart/form-data" id="apply_form">
        
        <ul>
            <li>
                <h2>{$lang.owner_name}</h2>
                <div class="arrange"><input type="text" class="text width7" name="owner_name" value="{$store.owner_name|escape}"/></div>
            </li>
            <li>
                <h2>{$lang.owner_card}</h2>
                <div class="arrange"><input type="text" class="text width7" name="owner_card" value="{$store.owner_card|escape}"></div>
            </li>
            <li>
                <h2>{$lang.store_name}</h2>
                <div class="arrange"><input type="text" class="text width7" name="store_name" id="store_name" value="{$store.store_name|escape}"/></div>
            </li>
            <li>
                <h2>{$lang.store_category}</h2>
                <div class="arrange">
                    <select name="cate_id">
                        <option value="0">{$lang.select_pls}</option>
                        {html_options options=$scategories selected=$scategory.cate_id}
                    </select>
                </div>
            </li>
            <li>
                <h2>{$lang.region}</h2>
                <div class="arrange" id="region">
                    <input type="hidden" name="region_id" value="{$store.region_id}" class="mls_id" />
                    <input type="hidden" name="region_name" value="{$store.region_name}" class="mls_names" />
                    {if $store.region_name}
                    <span>{$store.region_name|escape}</span>
                    <input type="button" value="{$lang.edit}" class="edit_region" />
                    {/if}
                    <select class="d_inline"{if $store.region_name} style="display:none;"{/if}>
                            <option value="0">{$lang.select_pls}</option>
                        {html_options options=$regions}
                    </select>
                </div>
            </li>
            
            <li>
                <h2>{$lang.address}</h2>
                <div class="arrange"><input type="text" class="text width7" name="address" value="{$store.address|escape}"/></div>
            </li>
            <li>
                <h2>{$lang.zipcode}</h2>
                <div class="arrange"><input type="text" class="text width7" name="zipcode" value="{$store.zipcode|escape}"/></div>
            </li>
            <li>
                <h2>{$lang.tel}</h2>
                <div class="arrange"><input type="text" class="text width7" name="tel"  value="{$store.tel|escape}"/></div>
            </li>
            <li>
                <h2>{$lang.upload_image} </h2>
                <div class="arrange"><input type="file" name="image_1" />{if $store.image_1}<p style="display:inline;"><a href="{$site_url}/{$store.image_1}" target="_blank">{$lang.view}</a></p>{/if}</div>
            </li>
            <li>
                <h2>{$lang.upload_permit}</h2>
                <div class="arrange"><input type="file" name="image_2" />{if $store.image_2}<p style="display:inline;"><a href="{$site_url}/{$store.image_2}" target="_blank">{$lang.view}</a></p>{/if}</div>
            </li>
            <li>
                <div class="arrange" style="margin:10px 0;"><input type="checkbox"{if $store} checked="checked"{/if} name="notice" value="1" id="warning" /> <label for="warning">{$lang.notice}</label></div>
            </li>
        </ul>
        <input class="btn" type="submit" value="申请" />
    </form>
</div>
{include file=footer.html}
